home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / povray < prev    next >
Encoding:
Text File  |  2010-11-16  |  2.1 KB  |  66 lines

  1. # povray completion by "David Necas (Yeti)" <yeti@physics.muni.cz>
  2.  
  3. have povray || have xpovray || have spovray &&
  4. _povray()
  5. {
  6.     local cur prev povcur pfx oext defoext
  7.     defoext=png # default output extension, if cannot be determined FIXME
  8.  
  9.     COMPREPLY=()
  10.     _get_comp_words_by_ref povcur prev
  11.  
  12.     _expand || return 0
  13.  
  14.     case $povcur in
  15.         [-+]I*)
  16.             cur="${povcur#[-+]I}" # to confuse _filedir
  17.             pfx="${povcur%"$cur"}"
  18.             _filedir pov
  19.             COMPREPLY=( ${COMPREPLY[@]/#/$pfx} )
  20.             return 0
  21.             ;;
  22.         [-+]O*)
  23.             # guess what output file type user may want
  24.             case $( ( IFS=$'\n'; command grep '^[-+]F' <<<"${COMP_WORDS[*]}" ) ) in
  25.                 [-+]FN) oext=png ;;
  26.                 [-+]FP) oext=ppm ;;
  27.                 [-+]F[CT]) oext=tga ;;
  28.                 *) oext=$defoext ;;
  29.             esac
  30.             # complete filename corresponding to previously specified +I
  31.             COMPREPLY=( $( ( IFS=$'\n'; command grep '^[-+]I' <<<"${COMP_WORDS[*]}" ) ) )
  32.             COMPREPLY=( ${COMPREPLY[@]#[-+]I} )
  33.             COMPREPLY=( ${COMPREPLY[@]/%.pov/.$oext} )
  34.             cur="${povcur#[-+]O}" # to confuse _filedir
  35.             pfx="${povcur%"$cur"}"
  36.             _filedir $oext
  37.             COMPREPLY=( ${COMPREPLY[@]/#/$pfx} )
  38.             return 0
  39.             ;;
  40.         *.ini\[|*.ini\[*[^]]) # sections in .ini files
  41.             cur="${povcur#*\[}"
  42.             pfx="${povcur%\["$cur"}" # prefix == filename
  43.             [ -r "$pfx" ] || return 0
  44.             COMPREPLY=( $(sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' \
  45.                 -e 't' -e 'd' -- "$pfx") )
  46.             # to prevent [bar] expand to nothing.  can be done more easily?
  47.             COMPREPLY=( "${COMPREPLY[@]/#/$pfx[}" )
  48.             return 0
  49.             ;;
  50.         *)
  51.             cur="$povcur"
  52.             _filedir '?(ini|pov)'
  53.             return 0
  54.             ;;
  55.     esac
  56. } &&
  57. complete -F _povray -o filenames povray xpovray spovray
  58.  
  59. # Local variables:
  60. # mode: shell-script
  61. # sh-basic-offset: 4
  62. # sh-indent-comment: t
  63. # indent-tabs-mode: nil
  64. # End:
  65. # ex: ts=4 sw=4 et filetype=sh
  66.